var Apply = function(){

    return {
        init: function () {

            $("#all_students").select2({
                ajax: {
                        url: "teach/get_all_students",
                        dataType: 'jsonp',
                        data: function (term, page) {
                            return {
                                q: term, // search term
                                page_limit: 10
                            };
                        },
                        results: function (data, page) { // parse the results into the format expected by Select2.
                            // since we are using custom formatting functions we do not need to alter remote JSON data
                            return {results: data};
                        }
                    },
                id:'student_id',
                 formatResult:function (student){ return student.student_name; },
                 formatSelection:function (student){ return student.student_name; },
                 escapeMarkup: function (m) { return m; }
            });
        }
    };
}();
